/*    */ package dm.jdbc.rsCache;
/*    */ 
/*    */ import dm.jdbc.desc.GlobalControlCfg;
/*    */ import dm.jdbc.driver.DmdbCSI;
/*    */ import dm.jdbc.driver.DmdbConnection_bs;
/*    */ import dm.jdbc.driver.DmdbResultSet_bs;
/*    */ import dm.jdbc.driver.DmdbStatement_bs;
/*    */ import java.sql.SQLException;
/*    */ import java.util.Calendar;
/*    */ 
/*    */ public class DmdbCachedResultSet
/*    */ {
/*    */   private long m_lastChkTime;
/* 14 */   private DmdbResultSet_bs m_rs = null;
/* 15 */   private long[] m_TbIds = null;
/* 16 */   private long[] m_TbTss = null;
/*    */   
/*    */   DmdbCachedResultSet(DmdbResultSet_bs rs, long[] tbIds, long[] tbTss) throws SQLException
/*    */   {
/* 20 */     if (rs != null) {
/* 21 */       this.m_rs = ((DmdbResultSet_bs)rs.clone());
/*    */     }
/* 23 */     this.m_TbIds = ((long[])tbIds.clone());
/* 24 */     this.m_TbTss = ((long[])tbTss.clone());
/* 25 */     this.m_lastChkTime = Calendar.getInstance().getTimeInMillis();
/*    */   }
/*    */   
/*    */   boolean refreshed(DmdbConnection_bs conn) throws SQLException
/*    */   {
/* 30 */     if (GlobalControlCfg.getRsRefreshFreq() == 0) {
/* 31 */       return false;
/*    */     }
/*    */     
/* 34 */     if (this.m_lastChkTime + GlobalControlCfg.getRsRefreshFreq() * 1000 > Calendar.getInstance().getTimeInMillis()) {
/* 35 */       return false;
/*    */     }
/* 37 */     long[] tss = DmdbCSI.table_ts(conn, this.m_TbIds);
/*    */     
/* 39 */     this.m_lastChkTime = Calendar.getInstance().getTimeInMillis();
/*    */     
/* 41 */     int tbCount = tss == null ? 0 : tss.length;
/* 42 */     if (tbCount != this.m_TbTss.length) {
/* 43 */       return true;
/*    */     }
/* 45 */     for (int i = 0; i < tbCount; i++) {
/* 46 */       if (this.m_TbTss[i] != tss[i]) {
/* 47 */         return true;
/*    */       }
/*    */     }
/* 50 */     return false;
/*    */   }
/*    */   
/*    */   DmdbResultSet_bs getResultSet(DmdbStatement_bs stmt) throws SQLException {
/* 54 */     DmdbResultSet_bs rs = (DmdbResultSet_bs)this.m_rs.clone();
/*    */     
/* 56 */     rs.setStatement(stmt);
/* 57 */     rs.setFetchDirection(stmt.getFetchDirection());
/* 58 */     rs.setConcurrencyType(stmt.getResultSetConcurrency());
/* 59 */     rs.setHoldability(stmt.getResultSetHoldability());
/* 60 */     rs.maxRows = stmt.getMaxRows();
/*    */     
/* 62 */     return rs;
/*    */   }
/*    */   
/*    */   long getLastChkTime() {
/* 66 */     return this.m_lastChkTime;
/*    */   }
/*    */   
/*    */   long getDataLen() {
/* 70 */     if (this.m_rs == null) {
/* 71 */       return 0L;
/*    */     }
/* 73 */     return this.m_rs.getDataLen();
/*    */   }
/*    */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\rsCache\DmdbCachedResultSet.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */